<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui">


    <ui:define name="content">

     sdfsdfsdfsd
     #{webUserController.hasPrivilege('AdminManagingUsers') or sessionController.firstLogin }
     aaaaaa
        <h:panelGroup rendered="#{webUserController.hasPrivilege('AdminManagingUsers') or sessionController.firstLogin }" >
            <h:form  >
                <p:panel header="Allowed Payment Schemes for Users" >
                    <h:panelGrid  columns="2" >                          
                        <h:outputLabel value="Select User"/>
                        <p:autoComplete id="user" converter="webUs" forceSelection="true" 
                                        completeMethod="#{webUserController.completeUser}" var="us"
                                        itemLabel="#{us.webUserPerson.name}" itemValue="#{us}"  
                                        value="#{userPaymentSchemeController.selectedUser}" >
                            <f:ajax event="itemSelect" execute="user" render="ins" />
                        </p:autoComplete>
                    </h:panelGrid>
                    <h:panelGrid columns="2" id="ins">
                        <p:panel header="PaymentSchme allowed for this user are">
                            <p:dataTable  value="#{userPaymentSchemeController.items}" var="i">
                                <p:column headerText="Discount Scheme">
                                    <h:outputLabel value="#{i.paymentScheme.name}"/>                              
                                </p:column>
                            </p:dataTable>                        
                        </p:panel>
                    </h:panelGrid>

                    <p:panelGrid columns="2">
                        <p:panel>
                            <h:outputText value="Paymentscheme" ></h:outputText>
                            <p:selectOneMenu id="dept2" value="#{userPaymentSchemeController.currentPaymentScheme}">
                                <f:selectItem itemLabel="Please select a Paymentscheme"/>
                                <f:selectItems value="#{paymentSchemeController.items}" var="d" itemLabel="#{d.name}" itemValue="#{d}" />
                            </p:selectOneMenu>
                        </p:panel>
                        <h:commandButton id="btnAddPaymentScheme" value="Add Discount Scheme" action="#{userPaymentSchemeController.addPaymentSchemeForUser()}"/>
                        <p:defaultCommand target="btnAddPaymentScheme"/>
                    </p:panelGrid>

                </p:panel>

            </h:form>

        </h:panelGroup>

    </ui:define>

</ui:composition>
